class code2 {
    //滑动窗口
    public int lengthOfLongestSubstring(String s) {
        //1.left ，right
        //2.进窗口
        //3.判断
            //出窗口
        //更新结果

        int[] hash = new int[128];
        int ret = 0;
        int left=0,right=0;

        while(right<s.length()) {
            hash[s.charAt(right)]++;
            while(hash[s.charAt(right)]>1) {
                hash[s.charAt(left++)]--;
            }
            ret = Math.max(ret,right-left+1);
            right++;
        }
        return ret;
    }
}